package com.example.ball.Fragment;

import android.app.Activity;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.Animation;

/**
 * Created by Administrator on 2016/7/12.
 */
public abstract class BaseFragment extends Fragment {

    private View layoutView;

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        if (layoutView==null) throw new NullPointerException("布局错误");
       else  return  layoutView;
    }


    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        findView();
        initView();
    }

    public   void  setContentView(View layoutView){
        this.layoutView=layoutView;

    }
     public   void  setContentView ( int layoutSId){
         layoutView=View.inflate(getActivity(),layoutSId,null);
    }
    public View  findViewById(int ById){
        if (layoutView==null) throw new NullPointerException("布局错误");
        else  return layoutView.findViewById(ById);
    }


   protected  abstract void findView();
   protected  abstract  void  initView();
}
